﻿<cfsilent>
	<cfscript>
	
		teacherName = event.getArg('TNAME','未指定');
		
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");

		sql = "SELECT a.institute_id,
					  a.institute_name
				FROM t_institute a 
				WHERE a.institute_id = :insId ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="insId", value=event.getArg("DepID"), cfsqltype="cf_sql_varchar" );
		rs_department= queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT  a.sbj_id,a.sbj_name,
					   a.subject_code,a.sbj_short,
					   a.institute_id,a.level_code,
					   a.term_start,a.sbj_english,
					   a.b_id,a.schooling_length
				FROM t_subject a 
				WHERE a.sbj_id = :SubjectId  ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="SubjectId", value=event.getArg("SubID"), cfsqltype="cf_sql_varchar" );
		rs_subject= queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT  a.b_id,
					   a.learning_branch 
				FROM t_learning_branch a 
				ORDER BY a.b_id ASC";
		queryObj = new Query( datasource=application.dnsSlave ); 
		rs_branch= queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT  a.sbj_id,
					   a.sbj_name,
					   a.sbj_short,
					   a.sbj_english
				FROM t_subject a 
				WHERE a.sbj_id LIKE :parent  ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="parent", value=rs_subject.sbj_id & '_', cfsqltype="cf_sql_varchar" );
		rs_dir= queryObj.execute( sql=sql ).getResult();
	
		sql = "SELECT  a.institute_id,
					   a.institute_name
				FROM t_institute a  
				WHERE a.classification = '1' 
				ORDER BY a.institute_name ASC";
		queryObj = new Query( datasource=application.dnsSlave ); 
		rs_ins= queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT  a.campus_id ,
					   a.campus_name 
				FROM t_campus a  
				ORDER BY a.campus_id ASC";
		queryObj = new Query( datasource=application.dnsSlave ); 
		rs_campus= queryObj.execute( sql=sql ).getResult();

		sql = "SELECT a.grade, count(a.cls_id) cls_id, 
					  sum(a.cls_size) cls_size, sum(a.cls_scale) cls_scale 
				FROM t_class a  
				WHERE a.sbj_id = :subject 
				GROUP BY a.grade 
				ORDER BY a.grade DESC";
		queryObj = new Query( datasource=application.dnsSlave ); 
		queryObj.addParam( name="subject", value=rs_subject.sbj_id, cfsqltype="cf_sql_varchar" );
		rs_grade= queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "教学运行基础数据 - 行政建制 - 专业概况 - " & rs_subject.sbj_name);

		targetArgs = structNew();
		structInsert(targetArgs, "DepID", rs_department.institute_id, true);
		structInsert(targetArgs, "SubID", rs_subject.sbj_id, true);

		currentTab = event.getArg("TabID", "labDirection");
		
		classId = event.getArg("CLSID");
		
		if( len(classId) ){
			
			sql = "SELECT t_class.cls_name, t_teacher.tch_id, t_teacher.tch_name 
					FROM t_class 
						 LEFT JOIN t_teacher ON t_teacher.tch_id = t_class.teacher_in_charge 
					WHERE cls_id = :classId";
			
			queryObj = new Query( datasource=application.dnsSlave ); 
			queryObj.addParam( name="classId", value=classId, cfsqltype="cf_sql_char" );
			rs_classEntity = queryObj.execute( sql=sql ).getResult();
			
			currentTab = "labteacherSet";	
		}
		
		sql = "SELECT t.academic_year, t.academic_term, t.term_start FROM t_term t ORDER BY academic_year DESC, academic_term";
		
		queryObj = new Query( datasource=application.dnsSlave );
		
		rs_term = queryObj.execute( sql=sql ).getResult();

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('instituteSetting', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText"><cfoutput>#rs_department.institute_name#</cfoutput>概况</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i><cfoutput>#rs_subject.sbj_name#</cfoutput>专业概况
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labBaseInfo">class="active"</cfif> id="labBaseInfo" tabTarget="BaseInfo">专业基础信息</span>
						<span <cfif currentTab eq "labDirection">class="active"</cfif> id="labDirection" tabTarget="Direction">专业方向设置</span>
						<span <cfif currentTab eq "labFormClass">class="active"</cfif> id="labFormClass" tabTarget="FormClass">行政班建制</span>
						<span <cfif currentTab eq "labPatchCreate">class="active"</cfif> id="labPatchCreate" tabTarget="PatchCreate">创建行政班</span>
						<cfif len(classId)>
							<span <cfif currentTab eq "labteacherSet">class="active"</cfif> id="labteacherSet" tabTarget="teacherSet">设置班主任</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="BaseInfo" class="tabContent">
					
					<cfif currentTab eq "labBaseInfo">
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>专业基础数据已更新</h3>
							<p>你可以通过上面的标签切换, 分别查阅到专业下设的专业主修方向信息以及课程体系设置概况.</p>
						</div>
					</cfif>
					
					<form id="formEdit" onSubmit="javascript:return processVerfiyForm('formEdit');" class="formWrapper" method="post" action="<cfoutput>#buildURL('subjectUpdateDo')#</cfoutput>">
						
						<input type="hidden" name="SubjectID" value="<cfoutput>#rs_subject.sbj_id#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>专业正式名称</b>
							<input name="SubjectName" id="SubjectName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#event.getArg('SubjectName', rs_subject.sbj_name)#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>国家专业代码</b>
							<input name="SubjectCode" id="SubjectCode" type="text" class="typeCode" verification="required" maxlength="6" value="<cfoutput>#event.getArg('SubjectCode', rs_subject.subject_code)#</cfoutput>" />
							<p class="notice">国家专业代码请参阅教育部标准 JB/BSSZY-2006 《授予博士、硕士学位和培养研究生的学科、专业代码》规范填写</p>
						</div>
						
						<div class="label">
							<span class="req">*</span><b>专业简称</b>
							<input name="SubjectShortName" id="SubjectShortName" type="text" class="typeTextTiny" verification="required" maxlength="10" value="<cfoutput>#event.getArg('SubjectShortName', rs_subject.sbj_short)#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>托管院系(部)</b>
							<select name="InstituteID">
                                <cfloop query="rs_ins"  >
									<option <cfif event.getArg('InstituteID', rs_subject.institute_id) eq rs_ins.institute_id>selected="selected"</cfif> value="<cfoutput>#rs_ins.institute_id#</cfoutput>"><cfoutput>#rs_ins.institute_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<div class="label">
							<b>培养层次</b>
							<input name="StudentLevel" type="radio" class="typeRadio" value="3" <cfif event.getArg('StudentLevel', rs_subject.level_code) eq "3">checked="checked"</cfif> />本科
							<input name="StudentLevel" type="radio" class="typeRadio" value="4" <cfif event.getArg('StudentLevel', rs_subject.level_code) eq "4">checked="checked"</cfif> />专科
						</div>
						
						<div class="label">
							<b>招生学期</b>
							<input name="TermStart" type="radio" class="typeRadio" value="1" <cfif event.getArg('TermStart', rs_subject.term_start) eq "1">checked="checked"</cfif> />秋季
							<input name="TermStart" type="radio" class="typeRadio" value="2" <cfif event.getArg('TermStart', rs_subject.term_start) eq "2">checked="checked"</cfif> />春季
						</div>
						
						<hr/>
						
						<div class="label">
							<b>英文名称</b>
							<input name="SubjectEnglish" id="SubjectEnglish" type="text" class="typeText typeEnglish" maxlength="180" value="<cfoutput>#event.getArg('SubjectEnglish', rs_subject.sbj_english)#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>学科门类</b>
							<select name="LearningBranch">
                                <cfloop query="rs_branch" >
									<option <cfif event.getArg('LearningBranch', rs_subject.b_id) eq rs_branch.b_id>selected="selected"</cfif> value="<cfoutput>#rs_branch.b_id#</cfoutput>"><cfoutput>#rs_branch.learning_branch#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<div class="label">
							<b>学制</b>
							<input name="SchoolingLength" type="radio" class="typeRadio" value="2.5" <cfif event.getArg('SchoolingLength', rs_subject.schooling_length) eq 2.5>checked="checked"</cfif>/>两年半
							<input name="SchoolingLength" type="radio" class="typeRadio" value="3" <cfif event.getArg('SchoolingLength', rs_subject.schooling_length) eq 3>checked="checked"</cfif>/>三年
							<input name="SchoolingLength" type="radio" class="typeRadio" value="4" <cfif event.getArg('SchoolingLength', rs_subject.schooling_length) eq 4>checked="checked"</cfif>/>四年
							<input name="SchoolingLength" type="radio" class="typeRadio" value="5" <cfif event.getArg('SchoolingLength', rs_subject.schooling_length) eq 5>checked="checked"</cfif>/>五年
							<input name="SchoolingLength" type="radio" class="typeRadio" value="7" <cfif event.getArg('SchoolingLength', rs_subject.schooling_length) eq 7>checked="checked"</cfif>/>七年
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button" type="reset" value="重设表格" />
						</div>
					</form>
					
					<div class="systemNotice">
						<h3><span class="img icon16x16 info"></span>删除专业信息</h3>
						<p>注意: 删除一个专业信息的同时, 会同时删除与专业相关所有行政建制数据信息. </p>
						<p>如果您确定<cfoutput>#rs_subject.sbj_name#</cfoutput>在当前的行政建制中未使用, 并且该专业没有任何学生时, 您可以在这里进行信息删除. 如果该专业还有行政班或培养方案等信息, 由于数据完整性维护的强制性要求, 这些相关信息会被同样删除. </p>
						
						<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('subjectRemoveDo')#</cfoutput>">
							<input type="hidden" name="InstituteID" value="<cfoutput>#rs_subject.institute_id#</cfoutput>" />
							<input type="hidden" name="SubjectID" value="<cfoutput>#rs_subject.sbj_id#</cfoutput>" />
							<div class="lable"><input class="button2" type="submit" value="删除专业及相关信息" /></div>
						</form>
						
					</div>
					
				</div>
				
				<div id="Direction" class="tabContent">
					
					<cfif rs_dir.recordCount>
							<div class="noticeBlock">
								<h3><cfoutput>#rs_subject.sbj_name#</cfoutput>专业主修方向</h3>
								<p><span class="img icon16x16 message"></span>这里列出的是<cfoutput>#rs_subject.sbj_name#</cfoutput>专业下设的学生修读学科方向. 如果您需要设置新的主修专业方向, <a href="javascript:showCreateFrom();">可以通过点击这里进行</a></p>
								<hr/>
							</div>
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								function showCreateFrom() {
									$("form#formCreate").toggleClass("hidden_elem");
									return void(0);
								}
								// -->
								//]]>				
							</script>
							
							<div class="clearfix">
								
								<cfset row = 0 />
								<table id="directGrid" class="UIEditable">
									<thead>
										<tr>
											<td></td>
											<td>专业方向</td>
											<td>简称</td>
											<td>英文</td>
											<td></td>
										</tr>
									</thead>
									<tbody>
                                    <cfloop query="rs_dir" >
										<cfset row++ />
										<tr class="editRows" rowid="<cfoutput>#rs_dir.sbj_id#</cfoutput>">
											<td width="20">
												<div class="deactive index forDelete">
													<cfoutput>#numberFormat(row, '0_')#</cfoutput>
												</div>
												<div class="active">
													<a href="javascript:void(0);" class="stat delete" rowid="<cfoutput>#rs_dir.sbj_id#</cfoutput>"></a>
												</div>
											</td>
											<td width="200">
												<div class="deactive forSubjectName">
													<cfoutput>#rs_dir.sbj_name#</cfoutput>
												</div>
												<div class="active">
													<input style="width:150px;" class="activeTextAuto" rowid="<cfoutput>#rs_dir.sbj_id#</cfoutput>" name="SubjectName" type="text" value="<cfoutput>#rs_dir.sbj_name#</cfoutput>" />
												</div>
											</td>
											<td width="80">
												<div class="deactive forSubjectShortName">
													<cfoutput>#rs_dir.sbj_short#</cfoutput>
												</div>
												<div class="active">
													<input style="width:60px;" class="activeTextAuto" rowid="<cfoutput>#rs_dir.sbj_id#</cfoutput>" name="SubjectShortName" type="text" value="<cfoutput>#rs_dir.sbj_short#</cfoutput>" />
												</div>
											</td>
											<td>
												<div class="deactive forSubjectEnglish">
													<span class="english"><cfoutput>#rs_dir.sbj_english#</cfoutput></span>
												</div>
												<div class="active">
													<input style="width:300px;" class="activeTextAuto" rowid="<cfoutput>#rs_dir.sbj_id#</cfoutput>" name="SubjectEnglish" type="text" value="<cfoutput>#rs_dir.sbj_english#</cfoutput>" />
												</div>
											</td>
											<td width="18">
												<span rowid="<cfoutput>#rs_dir.sbj_id#</cfoutput>" class="stat saved"></span>
											</td>
										</tr>
									</cfloop>
									</tbody>
								</table>
								
								<script language="javascript" type="text/javascript">
									//<![CDATA[
									<!--
									$(document).ready(function() {
										
										/* init inlineEdit */
										$("tr.editRows", "#directGrid.UIEditable").each(function(index, element) {
											
											$(this).dblclick(function(e) {
								
												var $row = $(this);
												var rowid = $row.attr("rowid");
								
												$("div.deactive", $row).hide("fast", function(){
													$("div.active", $row).show("fast");
												});

												$("span.stat", $row).removeClass("saved").addClass("save");
											});
											
										});
										
										/* form element blur reset */
										$("span.stat", "#directGrid.UIEditable tr.editRows").click(function(){
											
											var rowid = $(this).attr("rowid");
											var $row = $("tr.editRows[rowid='" + rowid + "']", "#directGrid.UIEditable");
							
											$("span.stat", $row).removeClass("waiting").removeClass("save").removeClass("checked").addClass("saved");
										
											$("div.active", $row).hide("fast", function(){
												$("div.deactive", $row).show("fast");								
											});
											
										});
										
										
										/* form delete trigger */
										$("a.delete", "#directGrid.UIEditable tr.editRows").click(function(){
											
											var rowid = $(this).attr("rowid");
											
											$.post(
													"<cfoutput>#buildURL('apiDirectionDelete')#</cfoutput>", 
													{
														'SubjectID' : rowid,
														'seed': (new Date()).getTime()
													}, 
													function(data) {
														
														result = $.parseJSON(data);
														
														var rowid = result.SubjectID;
														var $row = $("tr.editRows[rowid='" + rowid + "']", "#directGrid.UIEditable");
														
														$row.hide();
													});
											
											
										});
										
										/* form element trigger */
										$(":input", "#directGrid.UIEditable tr.editRows").change(function(e) {
										
											var rowid = $(this).attr("rowid");
											var $row = $("tr.editRows[rowid='" + rowid + "']", "#directGrid.UIEditable");
											
											if ($(this).val()) {
												$("span.stat", $row).removeClass("checked").removeClass("save").removeClass("info").addClass("waiting");
											
												/* parse field */
												var editedSubjectName = $(":input[name='SubjectName']", $row).val();
												var editedSubjectShortName = $(":input[name='SubjectShortName']", $row).val();
												var editedSubjectEnglish = $(":input[name='SubjectEnglish']", $row).val();
												
												$.post(
														"<cfoutput>#buildURL('apiDirectionUpdate')#</cfoutput>", 
														{
																'SubjectID' : rowid,
																'SubjectName' : editedSubjectName,
																'SubjectShortName' : editedSubjectShortName,
																'SubjectEnglish' : editedSubjectEnglish,
																'seed': (new Date()).getTime()
														}, 
														function(data) {
															
															result = $.parseJSON(data);
														
															var rowid = result.SubjectID;
															var $row = $("tr.editRows[rowid='" + rowid + "']", "#directGrid.UIEditable");
															
															var newSubjectName = result.SubjectName;
															var newSubjectShortName = result.SubjectShortName;
															var newSubjectEnglish = result.SubjectEnglish;
															
															$("div.forSubjectName", $row).text(newSubjectName);
															$("div.forSubjectShortName", $row).text(newSubjectShortName);
															$("div.forSubjectEnglish", $row).text(newSubjectEnglish);
															
															$("span.stat", $row).removeClass("waiting").addClass("save");
															
															$("div.active", $row).hide("fast", function(){
																$("div.deactive", $row).show("fast");								
															});
															
														});
												
											}
											else {
												$("span.stat", $row).removeClass("save").addClass("info");
											}
										
										});
										
									});
									// -->
									//]]>
								</script>
							</div>
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>尚未设置专业主修方向</h3>
								<p>当前您还没有设置<cfoutput>#rs_subject.sbj_name#</cfoutput>专业的主修方向分支, 请通过完善下列表单设置该专业的第一个主修分支.</p>
							</div>
					</cfif>
					
					<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper <cfif rs_dir.recordCount>hidden_elem</cfif>" method="post" action="<cfoutput>#buildURL('directionCreateDo')#</cfoutput>">
						
						<input type="hidden" name="SubjectID" value="<cfoutput>#rs_subject.sbj_id#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>专业方向</b>
							<input name="DirectionName" id="DirectionName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#event.getArg('DirectionName')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>专业方向简称</b>
							<input name="DirectionShortName" id="DirectionShortName" type="text" class="typeTextTiny" verification="required" maxlength="10" value="<cfoutput>#event.getArg('DirectionShortName')#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>英文名称</b>
							<input name="DirectionEnglish" id="DirectionEnglish" type="text" class="typeText typeEnglish" maxlength="180" value="<cfoutput>#event.getArg('DirectionEnglish')#</cfoutput>" />
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button" type="reset" value="重设表格" />
						</div>
					
					</form>
					
				</div>
				
				<div id="FormClass" class="tabContent">
					
					<cfif rs_grade.recordCount>
						<div id="classTables">
							<cfset arrayidx = 0 />
                            <cfloop query="rs_grade" >
								<cfset arrayidx++/>
								<div class="noticeBlock">
									<cfif arrayidx eq 1>
									<div class="operation">
										<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('classDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载班级数据</span></a>
									</div>
									</cfif>
									<h3><cfoutput>#rs_grade.grade#</cfoutput>级</h3>
									<p><span class="img icon16x16 message"></span>共计<em><cfoutput>#rs_grade.cls_id#</cfoutput></em>个行政班, 计划招生规模<em><cfoutput>#rs_grade.cls_size#</cfoutput></em>人, 实际学生人数<em><cfoutput>#rs_grade.cls_scale#</cfoutput></em>.</p>
									<hr/>
								</div>
								
								<cfset sql = "SELECT   a.cls_id, a.cls_name,
														CASE WHEN a.teacher_in_charge IS NULL THEN '-' ELSE a.teacher_in_charge END teacher_in_charge, 
													   b.campus_name,a.campus_id,
													   a.cls_size,a.cls_scale 
												FROM t_class a  
													 INNER JOIN t_campus b ON b.campus_id = a.campus_id
												WHERE a.sbj_id = :Subject  
													  AND
													  a.grade = :Grade "/>
								<cfset queryObj = new Query( datasource=application.dnsSlave ) />
								<cfset queryObj.addParam( name="Subject", value=rs_subject.sbj_id, cfsqltype="cf_sql_varchar" )/>
                                <cfset queryObj.addParam( name="Grade", value=rs_grade.grade, cfsqltype="cf_sql_char" )/>
								<cfset rs_class = queryObj.execute( sql=sql ).getResult()/>
								<cfset row = 0 />
								<table class="UIEditable">
									<thead>
										<tr>
											<td width="18"></td>
											<td>班级</td>
											<td width="120">班主任</td>
											<td width="20"></td>
											<td width="50"></td>
											<td width="120">所在校区</td>
											<td width="60" align="center">计划人数</td>
											<td width="60" align="center">学生数</td>
											<td width="18"></td>
										</tr>
									</thead>
									<tbody>
                                    <cfloop query="rs_class" >
									
										<cfset sql = "SELECT tch_id, tch_name FROM t_teacher WHERE tch_id = :teacherId" />
										
										<cfset queryObj = new Query( datasource=application.dnsSlave ) />
										
										<cfset queryObj.addParam( name="teacherId", value=rs_class.teacher_in_charge, cfsqltype="cf_sql_varchar" ) />
										
										<cfset rs_teacher = queryObj.execute( sql=sql ).getResult() /> 
											
										<cfset row++ />
											
										<tr title="双击修改" class="editRows" rowid="<cfoutput>#rs_class.cls_id#</cfoutput>">
											
											<cfset structInsert(targetArgs, "CLSID",rs_class.cls_id, true ) /> 
											<td>
												<div class="deactive index forDelete">
													<cfoutput>#numberFormat(row, '0_')#</cfoutput>
												</div>
												<div class="active forDelete">
													<a title="删除班级" href="javascript:void(0);" class="stat delete" rowid="<cfoutput>#rs_class.cls_id#</cfoutput>"></a>
												</div>
											</td>
											<td>
												<div class="deactive" forField="Name"><cfoutput>#rs_class.cls_name#</cfoutput></div>
												<div class="active" forField="Name">
													<input style="width:120px;" forField="Name" class="activeTextAuto" rowid="<cfoutput>#rs_class.cls_id#</cfoutput>" type="text" value="<cfoutput>#rs_class.cls_name#</cfoutput>" />
												</div>
											</td>
											<td>
												<cfif rs_teacher.recordCount>
														<div forField="tchName">
															<cfoutput>#rs_teacher.tch_name#</cfoutput>(<cfoutput>#rs_teacher.tch_id#</cfoutput>)
														</div>
													<cfelse>
														<div class="deactive" forField="tchName">-</div>
												</cfif>
											
											</td>
											<td>
												<div forField="update"><a class="btnSearch" href="<cfoutput>#buildURL('subjectSetting', targetArgs)#</cfoutput>" title="更换班主任"></a></div>
											</td>
											<td>
												<cfif rs_teacher.recordCount>
													<div forField="update"><a class="stat remove" href="<cfoutput>#buildURL('headTeacherDeleteDo', targetArgs)#</cfoutput>" title="删除班主任"></a></div>
												</cfif>
											</td>
											<td>
												<div class="deactive" forField="CampusID"><cfoutput>#rs_class.campus_name#</cfoutput></div>
												<div class="active" forField="CampusID">
													<select forField="CampusID" class="activeSelectAuto" rowid="<cfoutput>#rs_class.cls_id#</cfoutput>">
                                                        <cfloop query="rs_campus" >
															<option <cfif rs_campus.campus_id eq rs_class.campus_id>selected="selected"</cfif> value="<cfoutput>#rs_campus.campus_id#</cfoutput>"><cfoutput>#rs_campus.campus_name#</cfoutput></option>
														</cfloop>
													</select>
												</div>
											</td>
											<td align="center">
												<div class="deactive" forField="PlanSize"><span class="numeric"><cfoutput>#rs_class.cls_size#</cfoutput></span></div>
												<div class="active" forField="PlanSize">
													<input style="width:40px;" forField="PlanSize" class="activeTextAuto" rowid="<cfoutput>#rs_class.cls_id#</cfoutput>" type="text" maxlength="3" value="<cfoutput>#rs_class.cls_size#</cfoutput>" />
												</div>
											</td>
											<td align="center">
												<span class="numeric"><cfoutput>#rs_class.cls_scale#</cfoutput></span>
											</td>
											<td>
												<span title="保存" rowid="<cfoutput>#rs_class.cls_id#</cfoutput>" class="stat saved"></span>
											</td>
										</tr>
											
									</cfloop>
										<cfset structDelete(targetArgs, "CLSID") /> 
									</tbody>
								</table>
								
							</cfloop>
						</div>	
						
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {
								
									var $div = $("div#classTables");
								
									$("tr.editRows", $div).dblclick(function(e) {
									
										var rowid = $(this).attr("rowid");
										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
										
										$("div.deactive", $row).hide("fast", function(){
											$("div.active", $row).show("fast");
										});
										
										$("span.stat", $row).removeClass("saved").addClass("save");
									
									});
									
									/* form element blur reset */
									$("span.stat", $div).click(function(){
											
										var rowid = $(this).attr("rowid");
										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
							
										$("span.stat", $row).removeClass("waiting").removeClass("save").removeClass("checked").addClass("saved");
										
										$("div.active", $row).hide("fast", function(){
											$("div.deactive", $row).show("fast");
										});
											
									});
									
									/* form element trigger */
									$("select[forField]", $div).change(function(e) {
										
										var $input = $(this);
										var rowid = $input.attr("rowid");
										var field = $input.attr("forField");
										
										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
										
										var fieldCampusID = $(":input[forField='CampusID']", $row).val();
										
										$.post(
												"<cfoutput>#buildURL('apiClassUpdate')#</cfoutput>", 
												{
													'cid' : rowid,
													'CampusID' : fieldCampusID,
													'seed': (new Date()).getTime()
												},
												function(data) {
													
													result = $.parseJSON(data);
													
													var rowid = result.formClass.ClassID;
													var $row = $("tr.editRows[rowid='" + rowid + "']", $div);

													$("div[forField='CampusID'].deactive", $row).text(result.campus.CampusName);
													
												});
										
										$("div[forField=" + field + "].active", $row).hide("fast", function(){
											$("div[forField=" + field + "].deactive", $row).show("fast");
										});
										
									});
									
									$("input[forField]", $div).blur(function(e) {
										
										var $input = $(this);
										var rowid = $input.attr("rowid");
										var field = $input.attr("forField");
										
										var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
										
										var valueWas = $("div[forField=" + field + "].deactive", $row).text();
										
										/* 字段内容发生更新 */
										if (valueWas != $input.val()) {
											
											var fieldName = $(":input[forField='Name']", $row).val();
											var fieldPlanSize = $(":input[forField='PlanSize']", $row).val();
											
											$.post(
												"<cfoutput>#buildURL('apiClassUpdate')#</cfoutput>", 
												{
													'cid' : rowid,
													'Name' : fieldName,
													'PlanSize' : fieldPlanSize,
													'seed': (new Date()).getTime()
												}, 
												function(data) {
													
													result = $.parseJSON(data);
													
													var rowid = result.formClass.ClassID;
													var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
													
													$("div[forField='Name'].deactive", $row).text(result.formClass.Name);
													
													$("div[forField='PlanSize'].deactive", $row).text(result.formClass.PlanSize);
													
												});
										}
										
										$("div[forField=" + field + "].active", $row).hide("fast", function(){
											$("div[forField=" + field + "].deactive", $row).show("fast");
										});
										
									});
									
									/* form delete trigger */
									$("a.delete", $div).click(function(){
											
										var rowid = $(this).attr("rowid");
											
										$.post(
												"<cfoutput>#buildURL('apiClassDelete')#</cfoutput>", 
												{
													'cid' : rowid,
													'seed': (new Date()).getTime()
												}, 
												function(data) {
														
													result = $.parseJSON(data);
														
													var rowid = result.ClassID;
													var $row = $("tr.editRows[rowid='" + rowid + "']", $div);
														
													$row.hide();
												});
									});
								
								});
							// -->
							//]]>
						</script>
						
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>尚未设置行政班</h3>
								<p>当前您还没有设置<cfoutput>#rs_subject.sbj_name#</cfoutput>专业下属的行政班, 请通过上方的 "批量创建班级" 标签根据专业招生规模设置行政班信息.</p>
							</div>
					</cfif>
					
				</div>
				
				<div id="PatchCreate" class="tabContent">
				
					<div class="noticeBlock">
						<h3><cfoutput>#rs_subject.sbj_name#</cfoutput>专业：创建行政班</h3>
						<p><span class="img icon16x16 message"></span>“行政班”概念通常用于简化专业招生后的教学运行. 班级的数量和规模与当年招生专业人数息息相关. 如果您清楚<cfoutput>#rs_subject.sbj_name#</cfoutput>在某个年级的招生大致规模, 可以在这里快速的创建行政班.</p>
						<hr/>
					</div>
					
					<form id="formBatch" onSubmit="javascript:return processCreate2();" class="formWrapper" method="post" action="<cfoutput>#buildURL('classBatchCreateDo')#</cfoutput>">
						
						<input type="hidden" name="SubjectID" value="<cfoutput>#rs_subject.sbj_id#</cfoutput>" />
						<input id="TeacherID2" name="TeacherID2" type="hidden" value="" />
						
						<div class="label">
							<b>班级名称</b>
							<input name="ClassName" id="ClassName" type="text" class="typeText" style="width:150px;" value="" />
						</div>
						
						<div class="label">
							<b>计划招生人数</b>
							<input name="StudentCount" id="StudentCount" type="text" class="typeSmallInt" style="width:150px;" verification="integer" maxlength="4" value="0" />
							
						</div>
					
						<div class="label">
							<b>年级</b>
							<select name="Grade" >	
								<cfloop query="rs_term">
								<option <cfif rs_term.academic_year eq academicYear AND rs_term.academic_term eq academicTerm>selected="selected"</cfif> value="<cfoutput>#left(rs_term.academic_year,4)##rs_term.academic_term#</cfoutput>"><cfoutput>#rs_term.academic_year#学年第#rs_term.academic_term#学期</cfoutput></option>
								
								</cfloop>
							</select>
						</div>
						

						<div class="label">
							<b>班主任</b>
							<input name="TeacherName" id="TeacherName" type="text" disabled="disabled" class="typeTextDynamic " style="width:150px;" verification="required" value="<cfoutput>#teacherName#</cfoutput>" /><span id="teacherTrigger2" class="btnSearch"></span>
						</div>
						
						<div class="label">
							<span class="req">*</span><b>开学日期</b>
							<input name="DateStart" id="DateStart" type="text" class="typeDate" verification="date" maxlength="10" value="" readonly="readonly" /><span id="calendarTrigger" class="btnCalendar"></span>
						</div>
						
						<div class="label">
							<b>所在校区</b>
							<select name="CampusID">
                            	<cfloop  query="rs_campus" >
									<option value="<cfoutput>#rs_campus.campus_id#</cfoutput>"><cfoutput>#rs_campus.campus_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="生成行政班" />
							<input class="button" type="reset" value="重设表格" />
						</div>
						
						<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								function processCreate2() {
									
									var teacherID = $("form#formBatch input#TeacherID2").val();
									var clsName = $("form#formBatch input#ClassName").val();
									var dateStart = $("form#formBatch input#DateStart").val();
									var StudentCount = parseInt($("#StudentCount").val());
									
									if (teacherID != "") {
										
										if (StudentCount < 0) {
											$("#StudentCount").addClass("typeError").focus();
											return false;
										}
										
										if ( clsName == ""){
											$("#ClassName").addClass("typeError").focus();
											return false;
										}
										
										if ( dateStart == ""){
											$("#DateStart").addClass("typeError").focus();
											return false;
										}		
										
										return true;
									}
									else {
										alert("请先指定任课教师");
										
										$("#formBatch").addClass("hidden_elem");
										$("#teacherBox2").removeClass("hidden_elem");
										
										return false;
									}
									
								}
								
								$(document).ready(function() {
								
									$("#teacherTrigger2").click(function(){

										$("#formBatch").addClass("hidden_elem");
										$("#teacherBox2").removeClass("hidden_elem");

									});
									
									Calendar.setup({
										trigger    : "calendarTrigger",
										inputField : "DateStart",
										animation  : false
										});
																	
								});
								// -->
								//]]>
							</script>
						
					</form>
					
				</div>
				
				<div id="teacherSet" class="tabContent">
				
					<cfif len(classId)>
				
							<div class="noticeBlock">
								<h3><cfoutput>#rs_classEntity.cls_name#</cfoutput> 班主任修改</h3>
								<hr/>
							</div>
					
							<form id="formBatch2" onSubmit="javascript:return processCreate();" class="formWrapper hidden_elem" method="post" action="<cfoutput>#buildURL('headTeacherUpdate', targetArgs)#</cfoutput>">
							
								<input id="TeacherID2" name="TeacherID2" type="hidden" value="" />
								<input id="classId" name="classId" type="hidden" value="<cfoutput>#classId#</cfoutput>" />
						
								<div class="label">
									<b>班级</b>
									<cfoutput>#rs_classEntity.cls_name#</cfoutput>
								
								</div>
						
								<div class="label">
									<b>原班主任</b>
									<cfif rs_classEntity.tch_name NEQ "">
											<input name="TeacherName1" id="TeacherName1" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="<cfoutput>#rs_classEntity.tch_name#</cfoutput>(<cfoutput>#rs_classEntity.tch_id#</cfoutput>)" />
										<cfelse>
											<input name="TeacherName1" id="TeacherName1" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="未指定" />
									</cfif>
								</div>
						
								
								<div class="label">
									<b>修改为</b>
									<input name="TeacherName2" id="TeacherName2" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="" /><span title="搜索教师" id="teacherTrigger" class="btnSearch"></span>
								</div>
																
							
								<hr/>
						
								<div class="lable">
									<input class="button" type="submit" value="修改" />
								</div>
						
							</form>
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								function processCreate() {
									
									var teacherID = $("form#formBatch2 input#TeacherID2").val();
									
									if (teacherID != "") {
										
									}
									else {
										alert("请先指定任课教师");
										
										$("#formBatch").addClass("hidden_elem");
										$("#teacherBox2").removeClass("hidden_elem");
										
										return false;
									}
									
								}
								
								$(document).ready(function() {
								
									$("#teacherTrigger").click(function(){

										$("#formBatch2").addClass("hidden_elem");
										$("#teacherBox").removeClass("hidden_elem");

									});
																	
								});
								// -->
								//]]>
							</script>
					
						<cfelse>
						
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>没有设置任何专业信息</h3>
								<p>当前您还没有设置<cfoutput>#rs_department.institute_name#</cfoutput>下属的专业信息, 请先完成专业设置以后再创建专业下属的行政班.</p>
							</div>
						
					</cfif>
					
					<div id="teacherBox" class="">
						
						<form id="formSearchTeacher" class="formWrapper Transparent" method="post">
							<div class="label">
								<b>教师姓名或职工号</b>
								<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
							</div>
							<hr/>
							<div class="lable">
								<input class="button1" type="submit" value="搜索教师" />
								<input id="formSearchReset2" class="button" type="button" value="返回" />
							</div>
						</form>
							
						<div id="formSearchResult2" class="UICardTable"></div>
								
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							$("input#formSearchReset2").click(function(){
							
								$("#formBatch2").removeClass("hidden_elem");
								$("#teacherBox").addClass("hidden_elem");
									
							});
								
							$("#formSearchTeacher").submit(function(){
									
								if (processVerfiyForm('formSearchTeacher')) {
								
									$.getJSON(
											'<cfoutput>#buildURL("getTeacherByKeywords")#</cfoutput>',
											{
												'Keywords': $("form#formSearchTeacher input#Keywords").val(),
												'seed': (new Date()).getTime()
											},
											function(data) {
													
												$div = $("div#formSearchResult2").html("").removeClass("hidden_elem");
												$("form#formAuth").addClass("hidden_elem");
													
												for (var i=0; i<data.length; i++) {
												
													var $element = $("<dl><dt><a><i class='sex" + data[i][2] + "'></i><dd><h3>" + data[i][1] + " [" + data[i][3] + "]" + "</h3><p>(" + data[i][0] + ")</p></dd></a></dt></dl>");
														
													$element
														.attr({
															'TeacherID' : data[i][0],
															'TeacherName' : data[i][1]
														})
														.click(function(){
																
															var name = $(this).attr('TeacherName');
															var id = $(this).attr('TeacherID');
																
															$("form#formBatch2 input#TeacherID2").val(id);
															$("form#formBatch2 input#TeacherName2").val(name + "(" + id + ")");
																
															/* backForm */
															$("#formBatch2").removeClass("hidden_elem");
															$("#teacherBox").addClass("hidden_elem");
															
														})
														.appendTo($div);
														
												}
													
											});
									
								}
							
								return false;
							});
								
							// -->
							//]]>
						</script>
							
					</div>
					
				</div>
				
				<div id="teacherBox2" class="hidden_elem">
						
						<form id="formSearchTeacher2" class="formWrapper Transparent" method="post">
							<div class="label">
								<b>教师姓名或职工号</b>
								<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
							</div>
							<hr/>
							<div class="lable">
								<input class="button1" type="submit" value="搜索教师" />
								<input id="formSearchReset" class="button" type="button" value="返回" />
							</div>
						</form>
							
						<div id="formSearchResult" class="UICardTable"></div>
								
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							$("input#formSearchReset").click(function(){
							
								$("#formBatch").removeClass("hidden_elem");
								$("#teacherBox2").addClass("hidden_elem");
									
							});
								
							$("#formSearchTeacher2").submit(function(){
									
								if (processVerfiyForm('formSearchTeacher2')) {
								
									$.getJSON(
											'<cfoutput>#buildURL("getTeacherByKeywords")#</cfoutput>',
											{
												'Keywords': $("form#formSearchTeacher2 input#Keywords").val(),
												'seed': (new Date()).getTime()
											},
											function(data) {
													
												$div = $("div#formSearchResult").html("").removeClass("hidden_elem");
												$("form#formAuth").addClass("hidden_elem");
													
												for (var i=0; i<data.length; i++) {
												
													var $element = $("<dl><dt><a><i class='sex" + data[i][2] + "'></i><dd><h3>" + data[i][1] + " [" + data[i][3] + "]" + "</h3><p>(" + data[i][0] + ")</p></dd></a></dt></dl>");
														
													$element
														.attr({
															'TeacherID' : data[i][0],
															'TeacherName' : data[i][1]
														})
														.click(function(){
																
															var name = $(this).attr('TeacherName');
															var id = $(this).attr('TeacherID');
																
															$("form#formBatch input#TeacherID2").val(id);
															$("form#formBatch input#TeacherName").val(name + "(" + id + ")");
																
															/* backForm */
															$("#formBatch").removeClass("hidden_elem");
															$("#teacherBox2").addClass("hidden_elem");
															
														})
														.appendTo($div);
														
												}
													
											});
									
								}
							
								return false;
							});
								
							// -->
							//]]>
						</script>
							
					</div>
				
			
			</div>
		</li>
	</ul>
</div>